import requests
from fake_useragent import UserAgent

target_url = "https://www.mashangpa.com/api/problem-detail/3/data/"
headers = {
    "User-Agent": UserAgent().random
}
cookies = {
    "Cookie": "Hm_lvt_0d2227abf9548feda3b9cb6fddee26c0=1762247276; HMACCOUNT=06D1F1816DD4C515; sessionid=0g7yox9nfsjesmfqr72lsjakiq8fgpuu; Hm_lpvt_0d2227abf9548feda3b9cb6fddee26c0=1762252927"
}
for i in range(1, 21):
    params = {
        "page": i
    }
    response = requests.get(target_url, params=params, headers=headers, cookies=cookies)
    data = response.json()
    arr = data["current_array"]
    print(arr)
    sum = 0
    for item in arr:
        sum += int(item)
    print(sum)
